//
//  CounterViewControllerViewTest.m
//  Hello_OCUnit
//
//  Created by zhudongxia on 15/12/15.
//  Copyright © 2015年 zhudongxia. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "CounterViewController.h"
#define HC_SHORTHAND
#import <OCHamcrestIOS/OCHamcrestIOS.h>
#import "OCMock.h"
@interface CounterViewControllerViewTest : XCTestCase
{
    CounterViewController *sut;
    Counter *mockCounter;
}
@end

@implementation CounterViewControllerViewTest

- (void)setUp {
    [super setUp];
    self.continueAfterFailure = NO;
    mockCounter = OCMClassMock([Counter class]);
    sut = [[CounterViewController alloc]initWithCounter:mockCounter];
    [sut view];
    
    
    
}

-(void) testPlusButtonShuoldBeConnected
{
    assertThat([sut plusButton], is(notNilValue()));
}

-(void) testPlusButtonAction
{
    UIButton *button = [sut plusButton];
    assertThat([button actionsForTarget:sut forControlEvent:UIControlEventTouchUpInside], contains(@"incrementCount:",nil));
    
}

-(void) testIncrementCountShouldAdkCounterToIncrement
{
    [sut incrementCount:nil];
    OCMVerify([mockCounter increment]);
}

-(void) testModelChangedNotificationShouldUpdateCountLabel
{
    OCMStub([mockCounter count]).andReturn(2);
    [[NSNotificationCenter defaultCenter]postNotificationName:CounterModelChanged object:mockCounter];
    assertThat([[sut counterLabel]text], is(@"2"));
}




- (void)tearDown {
    sut = nil;
    [super tearDown];
}



@end
